<template>
    <div >
       <el-row :gutter="20">
             <el-col :span="12" :offset="6">{{msg}}</el-col>
           <el-col :span="12" :offset="6">
                <el-form ref="form" label-width="80px">
                    <el-form-item label="用户名">
                        <el-input v-model="name"></el-input>
                    </el-form-item>
                    <el-form-item label="密码">
                        <el-input v-model="pwd"></el-input>
                    </el-form-item>
                     <el-form-item>
                        <el-button type="success" @click="login">登录</el-button>
                        <el-button native-type="reset">重置</el-button>
                    </el-form-item>
                </el-form>   
            
            </el-col> 
       </el-row>
       
    </div>
</template>

<script>
export default {
    name: "",
    data() {
        return {
            name:'admin',pwd:'123456',
            msg:''
        }
    },
    components: {},
    methods: {
        login(){
             var url="/login/login";
             var params=new URLSearchParams();
             params.append("name",this.name);
             params.append("pwd",this.pwd);
            this.$axios.post(url,params).then(resp=>{
                 if(resp.data.tag){ 
                     this.msg='';
                     this.$store.dispatch("change",'index');
                     this.$store.dispatch("login",resp.data.data);
                }else{
                  this.msg="用户或密码错误"
                }
            });
        }
    }
}
</script>

<style  scoped>
</style>
